package com.glamour.hlcity.module.dom.analysis.impl;


import org.openide.util.lookup.ServiceProvider;
import com.glamour.hlcity.common.enums.ClassifiedEnum;
import com.glamour.hlcity.common.model.Node;
import com.glamour.hlcity.common.util.ListUtil;
import com.glamour.hlcity.module.dom.analysis.Classified;

/**
 * 
 * 父亲节点名称相等同时自身的标签名称相同
 * @author zhaoxing.liuzx
 *
 */
@ServiceProvider(service = Classified.class)
public class ParentAndTagNameClueClassified extends  GeneralClueClassified {

	private final static String TOP_TAG_NAME="hlcity_html_top_tag";
	private final static String TAG_NAME_TEXT = "hlcity_html_text_tag";
	@Override
	public ClassifiedEnum getClassifiedEnum() {
		// 仅父亲节点标签名称相同，该节点的标签名称也相同
		return ClassifiedEnum.ONLY_SAME_PARENT_AND_TAG_NAME;
	}
	@Override
	public String classifiedKeyValue(Node node){
		String result="";
		Node parent=node.getParentNode();
		if(parent==null){
			result.concat(TOP_TAG_NAME).concat("-") ;
		}else{
			result.concat(parent.getNodeName()).concat("-");
		}

		if(Node.HTML_ELEMENT_TAG.equals(node.getNodeType())){
			result.concat(node.getNodeName());
		}else{
			result.concat(TAG_NAME_TEXT);
		}
		return result;
	}

}
